<?
namespace pmvc\util;

use PHPUnit_Framework_TestCase;
use Exception;

class BitSetTest
	extends PHPUnit_Framework_TestCase {

	public function testEverything() {
		$bitset = new BitSet();
		$this->assertEquals(0, $bitset->getValue());
		
		$bitset->set(10, false);
		$this->assertFalse($bitset->get(10));
		$this->assertFalse($bitset[10]);
		$bitset->set(10, true);
		$this->assertTrue($bitset->get(10));
		$this->assertTrue($bitset[10]);
		$bitset->set(10, false);
		$this->assertFalse($bitset->get(10));
		$this->assertFalse($bitset[10]);

	}

	public function testIncrement() {
		$bitset = new BitSet();
		for ($i=0; $i<(PHP_INT_SIZE*8)-1; $i++) {
			$this->assertFalse($bitset->get($i), "bit ".$i." failed");
			$bitset->set($i, true);
			$this->assertTrue($bitset->get($i), "bit ".$i." failed");
		}
		for ($i=0; $i<(PHP_INT_SIZE*8)-1; $i++) {
			$this->assertTrue($bitset->get($i), "bit ".$i." failed");
		}
		for ($i=0; $i<(PHP_INT_SIZE*8)-1; $i++) {
			$this->assertTrue($bitset->get($i), "bit ".$i." failed");
			$bitset->set($i, false);
			$this->assertFalse($bitset->get($i), "bit ".$i." failed");
		}
		for ($i=0; $i<(PHP_INT_SIZE*8)-1; $i++) {
			$this->assertFalse($bitset->get($i), "bit ".$i." failed");
		}
	}
}

?>